<?php
	header("Content-Type: text/html;charset=utf-8");
	//include("function/_nosql.php"); //
	include("function/function.php");
//	include("_include.user.judge.php");
	$kboy_userid = $_SESSION['kboy_userid'];
	$kboy_user = $_SESSION['kboy_user'];
	if($_SESSION['kboy_user'] == "" && $_SESSION['kboy_phone'] == "" || $_SESSION['kboy_userid'] == ""){
		erro('请先登录！！');
	}
	$action = chkstr(trim($_REQUEST['action']));
	$newsid = chkstr(trim($_REQUEST['newsid']));
	$messagetext = addslashes($_REQUEST['messagetext']);
	$messagecode = chkstr(trim($_REQUEST['messagecode']));
	
   if($action == 'add'){
		$message_text = $messagetext;
		if(strlen($message_text) < 1){
			erro('评论内容不能为空');
		}
		if(strlen($newsid) < 1 || !isNumber($newsid)){
			erro('参数错误');
		}
		if($messagecode != $_SESSION['verifyCode']){
			echo erro("验证码错误");
		}
		
		$mysql = new sqlstr("kboy_active_message"); 
		$mysql -> set("uid",$kboy_userid,true);
		$mysql -> set("newsid",$newsid,true);
		$mysql -> set("message_text",$message_text);
		$add_sql = $mysql -> insertSql();
		$add_re = mysql_query($add_sql);
		if($add_re){
			re('activeview.php?newsid='.$newsid.'#d-hd-10');
		}else{
			erro('服务器内部错误');
		}
		
	}else{
		erro("参数错误");
	}